package com.example.smartcity_poverty.ui.poverty.adapter

import android.content.Intent
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.ui.AllService.StopWhere.StopSwAllActivity
import com.example.smartcity_poverty.ui.poverty.activity.MoreFourActivity
import com.example.smartcity_poverty.ui.poverty.activity.MoreOneActivity
import com.example.smartcity_poverty.ui.poverty.activity.MoreThreeActivity
import com.example.smartcity_poverty.ui.poverty.activity.MoreTwoActivity
import com.example.smartcity_poverty.ui.poverty.model.PtMoreEntity
import kotlinx.android.synthetic.main.re_item_poverty_more.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *
 **/
class PtMoreAdapter(
    private val list: MutableList<PtMoreEntity>,
    private val layoutId: Int
) : BaseRecyclerAdapter<PtMoreEntity>(list, layoutId) {
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: PtMoreEntity,
        position: Int,
        holder: BaseViewHolder
    ) {

        if (list.size <= 0){

        }else{
            val d = list[position]
            holder.viewFind.ptMoreImage.setImageResource(d.image)
            holder.viewFind.ptMoreTitle.text = d.title

            val con = holder.viewFind.view?.context

            holder.itemView.setOnClickListener {

                if (holder.viewFind.ptMoreTitle.text.toString() == "扶贫案例")
                    con?.startActivity(Intent(con, MoreOneActivity::class.java))

                if (holder.viewFind.ptMoreTitle.text.toString() == "村情村貌")
                    con?.startActivity(Intent(con, MoreTwoActivity::class.java))

                if (holder.viewFind.ptMoreTitle.text.toString() == "收到求助")
                    con?.startActivity(Intent(con, MoreThreeActivity::class.java))

                if (holder.viewFind.ptMoreTitle.text.toString() == "案例发布")
                    con?.startActivity(Intent(con, MoreFourActivity::class.java))

                if (holder.viewFind.ptMoreTitle.text.toString() == "停车记录")
                    con?.startActivity(Intent(con, StopSwAllActivity::class.java))

            }
        }



    }

}